﻿var GradeList = ['一年级', '二年级', '三年级', '四年级', '五年级', '六年级', '七年级(初一)', '八年级(初二)', '九年级(初三)', '高一', '高二', '高三'];
var ClassIndex = ['一班', '二班', '三班', '四班', '五班', '六班', '七班', '八班', '九班', '十班', '十一班', '十二班', '十三班', '十四班', '十五班', '十六班', '十七班', '十八班', '十九班', '二十班'];
function sleep(numberMillis) {
    var now = new Date();
    var exitTime = now.getTime() + numberMillis;
    while (true) {
        now = new Date();
        if (now.getTime() > exitTime)
            return;
    }
}
//获取url中的参数
function getUrlParam(name) {
    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
    var r = window.location.search.substr(1).match(reg);  //匹配目标参数
    if (r != null) return unescape(r[2]); return ""; //返回参数值
}
function jsunescape(cellvalue, options, cell) {
    return unescape(cellvalue);
}
function MessageAlert(info, fun) {
    layer.msg(info);
    (fun && typeof (fun) === "function") && fun();
    if (typeof (fun) == "string") {
        $("#" + fun).focus();
    } else {
        (fun && typeof (fun) === "function") && fun();
    }
    return;
}
function onclickCheckBox(itemID, obj, type, sText, sValue) {
    if (obj.checked) {
        document.all[itemID].style.backgroundColor = "#999999";
        //alert(type);
        if (type == "ModalDialog") {
            SelectItem(sText, sValue);
        }
    }
    else
        document.all[itemID].style.backgroundColor = "";
}
function SelectItem(itemID, cbid) {
    if (checklock)
        return;
    if (document.getElementById(cbid)) {
        if (document.getElementById(cbid).checked) {
            document.getElementById(cbid).checked = false;
        }
        else {
            document.getElementById(cbid).checked = true;
        }
        setItemBackColor(itemID, document.getElementById(cbid));
    }
}

function setItemBackColor(itemID, obj) {
    if (obj.checked) {
        document.getElementById(itemID).className = "trSelect";
    }
    else {
        document.getElementById(itemID).className = "";
    }
}
function ViewClick() {
    var i, sid, sid2, id, url;
    for (i = 0; i < arguments.length; i++) {
        if (i == 0) { sid = arguments[0]; }
        if (i == 1) { sid2 = arguments[1]; }
        if (i == 2) { id = arguments[2]; }
        if (i == 3) { url = arguments[3]; }
    }
    url = url + "&timetemp=" + (Math.random() * 10 + 1);
    document.getElementById(sid).className = "Cnone";
    document.getElementById(sid2).className = "";
    document.getElementById("DataGridtr" + id).style.display = "";
    document.getElementById("DataGridtd" + id).innerHTML = "<iframe name='DataGridiframe" + id + "' id='DataGridiframe" + id + "' width='100%' height='100%' src='" + url + "' frameborder=0></iframe>";
}
function ViewClose() {
    var i, sid, sid2, id, url;
    for (i = 0; i < arguments.length; i++) {
        if (i == 0) { sid = arguments[0]; }
        if (i == 1) { sid2 = arguments[1]; }
        if (i == 2) { id = arguments[2]; }
        if (i == 3) { url = arguments[3]; }
    }
    document.getElementById(sid).className = "Cnone";
    document.getElementById(sid2).className = "";
    document.getElementById("DataGridtr" + id).style.display = "none";

}
function MouseOut(obj) {
    if (document.getElementById(obj).className == "trHover")
        document.getElementById(obj).className = "";
}
function MouseOver(obj) {
    //alert(document.getElementById(obj).className);
    if (document.getElementById(obj).className != "trSelect")
        document.getElementById(obj).className = "trHover";
}
Date.prototype.format = function (fmt) {
    var o = {
        "M+": this.getMonth() + 1,                 //月份
        "d+": this.getDate(),                    //日
        "h+": this.getHours(),                   //小时
        "m+": this.getMinutes(),                 //分
        "s+": this.getSeconds(),                 //秒
        "q+": Math.floor((this.getMonth() + 3) / 3), //季度
        "S": this.getMilliseconds()             //毫秒
    };
    if (/(y+)/.test(fmt))
        fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
    for (var k in o)
        if (new RegExp("(" + k + ")").test(fmt))
            fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
    return fmt;
};
function selectAll() {
    var len = document.form1.elements.length;
    var i;
    checklock = true;
    for (i = 0; i < len; i++) {
        if (document.form1.elements[i].type == "checkbox") {
            var sname = document.form1.elements[i].name;

            var cutname = sname.substr(sname.lastIndexOf(":") + 1);
            if (cutname == "cboxiID") {
                if (!document.form1.elements[i].checked) {
                    document.form1.elements[i].click();
                }
                else {

                }
            }
        }
    }
    checklock = false;
    //设置全选时所有行背景色变化
    //    var Curr_TR = document.all.tags("tr");
    //    for (var i = 1; i < Curr_TR.length; i++) {
    //        var itemid = Curr_TR[i].id;
    //        if (itemid.lastIndexOf("_") == -1 && itemid.substr(0, 4) == "item")
    //            Curr_TR[i].style.backgroundColor = "#999999";
    //    }
}

function unSelectAll() {
    var len = document.form1.elements.length;
    var i;
    checklock = true;
    for (i = 0; i < len; i++) {
        if (document.form1.elements[i].type == "checkbox") {
            var sname = document.form1.elements[i].name;
            //alert(sname);
            var cutname = sname.substr(sname.lastIndexOf(":") + 1);
            if (cutname == "cboxiID") {
                document.form1.elements[i].click();
                //                if (document.form1.elements[i].checked == false)
                //                    document.form1.elements[i].checked = true;
                //                else
                //                    document.form1.elements[i].checked = false;
            }
        }
    }
    checklock = false;
    //设置取消时所有行背景色变化

    //    var Curr_TR = document.all.tags("tr");
    //    for (var i = 1; i < Curr_TR.length; i++) {
    //        var itemid = Curr_TR[i].id;
    //        if (itemid.lastIndexOf("_") == -1 && itemid.substr(0, 4) == "item")
    //            Curr_TR[i].style.backgroundColor = "";
    //    }
}
//=========================================================================================
//
//  代码描述：打开一个新的没有状态栏、工具栏、菜单栏、定位栏，不能改变大小，且位置居中的新窗口
//  传入参数：pageURL - 传递链接
//            innerWidth - 传递需要打开新窗口的宽度
//            innerHeight - 传递需要打开新窗口的高度
//  修改记录：姓名              日期                 内容
//           think           2005/04/11             创建
//
//=========================================================================================
function OpenWindow(pageURL, innerWidth, innerHeight) {
    var ScreenWidth = screen.availWidth
    var ScreenHeight = screen.availHeight
    var StartX = (ScreenWidth - innerWidth) / 2
    var StartY = (ScreenHeight - innerHeight) / 2
    if (innerWidth == null && innerHeight == null)
        window.open(pageURL)
    else
        window.open(pageURL, 'newwindow', 'left=' + StartX + ', top=' + StartY + ', Width=' + innerWidth + ', height=' + innerHeight + ', resizable=yes, scrollbars=yes, status=no, toolbar=no, menubar=no, location=no')
}
function btnover(id) {
    document.getElementById(id).className = document.getElementById(id).className + "hover";
}
function btnout(id) {
    document.getElementById(id).className = document.getElementById(id).className.replace("hover", "");
}
function ShowCenter(id) {
    document.getElementById(id).style.display = ""; //显示之后才能获取到高度和宽度
    var diffY;
    if (document.documentElement && document.documentElement.scrollTop)
        diffY = document.documentElement.scrollTop;
    else if (document.body)
        diffY = document.body.scrollTop;
    var obwidth = document.getElementById(id).offsetWidth;
    var obheight = document.getElementById(id).offsetHeight;
    var x = ($(document).width() - obwidth) / 2;
    var y = ($(document).height() - obheight + diffY) / 2;
    document.getElementById(id).style.left = x;
    document.getElementById(id).style.top = y;
}
jQuery.cookie = function (name, value, options) {
    if (typeof value != 'undefined') {
        options = options || {};
        if (value === null) {
            value = '';
            options = $.extend({}, options);
            options.expires = -1;
        }
        var expires = '';
        if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
            var date;
            if (typeof options.expires == 'number') {
                date = new Date();
                date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
            } else {
                date = options.expires;
            }
            expires = '; expires=' + date.toUTCString();
        }
        var path = options.path ? '; path=' + (options.path) : '';
        var domain = options.domain ? '; domain=' + (options.domain) : '';
        var secure = options.secure ? '; secure' : '';
        document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
    } else {
        var cookieValue = null;
        if (document.cookie && document.cookie != '') {
            var cookies = document.cookie.split(';');
            for (var i = 0; i < cookies.length; i++) {
                var cookie = jQuery.trim(cookies[i]);
                if (cookie.substring(0, name.length + 1) == (name + '=')) {
                    cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
                    break;
                }
            }
        }
        return cookieValue;
    }
};
function ShowPanel(id) {
    if (document.getElementById(id)) {
        if (document.getElementById(id).style.display == "")
            document.getElementById(id).style.display = "none";
        else
            document.getElementById(id).style.display = "";
    }
}
function subform(id) {
    if (id == "" || id == undefined)
        id = "form1";
    return $('#' + id + '').form('validate');
}
function CheckImg(vv) {
    //判断是否是图片 - strFilter必须是小写列举
    var strFilter = "jpeg|gif|jpg|png|bmp|pic|"
    var strPostfix = vv + '|';
    strPostfix = strPostfix.toLowerCase();
    if (strFilter.indexOf(strPostfix) > -1) {
        return true;
    }
    return false;
}
function CheckVideo(vv) {
    var strFilter = "mp4|avi|rmvb|mov|"
    var strPostfix = vv + '|';
    strPostfix = strPostfix.toLowerCase();
    if (strFilter.indexOf(strPostfix) > -1) {
        return true;
    }
    return false;
}
function isNUM(value) {
    return !isNaN(parseFloat(value)) && isFinite(value);
    //var mobile = /^[0-9][.]*$/;
    //return mobile.test(value);
}
function isNUMBER_HG(value) {
    var length = value.length;
    //alert(length);
    //alert(len);
    var mobile = /^[0-9\-]*[a-zA-Z]?$/;
    return mobile.test(value);
}
function isNUMBER(value, len) {
    var length = value.length;
    //alert(length);
    //alert(len);        
    var mobile = /^[0-9]*$/;
    return length == len && mobile.test(value);
}
//检查是否整数

function isTel(value) {
    var tel = /^\d{3,4}-?\d{7,9}$/; //电话号码格式010-12345678 
    return tel.test(value);
}
function isZCH(value) {
    var length = value.length;
    var mobile = /^\d{4}[a-zA-Z]{1}\d{4}$/;
    return length == 9 && mobile.test(value);
}
function isMobile(value) {
    var length = value.length;
    var mobile = /^(((13[0-9]{1})|(18[0-9]{1})|(15[0-9]{1}))+\d{8})$/;
    return length == 11 && mobile.test(value);
}


//document.write("<div id='BodyLoading' style='position: absolute; z-index: 1000; top: 0px; left: 0px;"
//        + "width: 100%; height: 100%; background: white; text-align: center;'>"
//        + "<h2 style='top: 48%; position: relative;'>"
//            + "<font color='#15428B'>加载中···</font>"
//        + "</h2>"
//    + "</div>");

//function closes() {
//    $("#BodyLoading").fadeOut("normal", function () {
//        $(this).remove();
//    });
//}

//var pc;
//$.parser.onComplete = function () {
//    if (pc) clearTimeout(pc);
//    pc = setTimeout(closes, 10);
//}
function ReLoadPage() {
    window.location.href = window.location.href.replace("#", "");
}
